#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;
const int N=1e3+10;

double dist[N];
vector<pair<int,double>> edge[N];
int n,m;
int wf[N];
int cnt[N];
int st[N];
bool check(double mid)
{
	memset(st,0,sizeof(st));
	memset(cnt,0,sizeof(cnt));
	memset(dist,0,sizeof(dist));
	queue<int> q;
	for(int i=1;i<=n;i++)
	{
		q.push(i);
		st[i]=1;
	}
	while(q.size())
	{
		int r=q.front();
		st[r]=0;
		q.pop();
		for(auto& e:edge[r])
		{
			int aim=e.first;
			double waim=e.second;
			if(dist[aim]<dist[r]+wf[r]-waim*mid)
			{
				dist[aim]=dist[r]+wf[r]-waim*mid;
				cnt[aim]=cnt[r]+1;
				if(cnt[aim]>=n)
					return true;
				if(!st[aim])
				{
					q.push(aim);
					st[aim]=1;
				}
			}
		}
	}
	return false;
}

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>wf[i];
		
	for(int i=0;i<m;i++)
	{
		int a,b;
		double t;
		cin>>a>>b>>t;
		edge[a].push_back({b,t});
	}
	double left=0,right=1000;
	while(right-left>1e-4)
	{
		double mid=(left+right)/2;
		if(check(mid))
		{
			left=mid;
		}
		else{
			right=mid;
		}
	}
	printf("%.2lf",left);
	return 0;
}
